package top.lixunda.ecommerce.server.good.api.entity.db;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author Xumda
 * @since 2019-12-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("good_order")
public class GoodOrderDO extends Model<GoodOrderDO> {

    private static final long serialVersionUID=1L;

    /**
     * flag 标志，未删除
     */
    public static final Integer FLAG_TRUE = 1;

    /**
     * flag 标志，已删除
     */
    public static final Integer FLAG_FALSE = 0;

    public static final String STATE_TO_PAY = "待支付";
    public static final String STATE_TO_TRANS = "待发货";
    public static final String STATE_TO_TRANSPORTING = "运输中";
    public static final String STATE_TO_RECEIVE = "待签收";
    public static final String STATE_RECEIVED = "已签收";
    public static final String STATE_TO_REFUND = "待退款";
    public static final String STATE_REFUNDED = "已退款";
    public static final String STATE_CANCEL = "已取消";
    public static final String STATE_END = "已完结";

    public static final String PAY_TYPE_WE_CHAT = "微信";
    public static final String PAY_TYPE_ALI_PAY = "支付宝";

    /**
     * 订单Id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 用户id
     */
    @TableField("user_id")
    private Integer userId;

    /**
     * 用户名
     */
    @TableField("user_name")
    private String userName;

    /**
     * 商家id，不能为空，为空时表示删除了店铺数据
     */
    @TableField("store_id")
    private Integer storeId;

    /**
     * 商家名称
     */
    @TableField("store_name")
    private String storeName;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 付款时间
     */
    @TableField("price_time")
    private LocalDateTime priceTime;

    /**
     * 发货时间
     */
    @TableField("good_time")
    private LocalDateTime goodTime;

    /**
     * 成交时间
     */
    @TableField("end_time")
    private LocalDateTime endTime;

    /**
     * 商品总价
     */
    @TableField("goods_price")
    private BigDecimal goodsPrice;

    /**
     * 运费
     */
    @TableField("freight")
    private BigDecimal freight;

    /**
     * 是否有运费险 1 有 0 没有
     */
    @TableField("have_freight_insu")
    private Integer haveFreightInsu;

    /**
     * 运费险
     */
    @TableField("freight_insu")
    private BigDecimal freightInsu;

    /**
     * 红包减免
     */
    @TableField("red_envelope")
    private BigDecimal redEnvelope;

    /**
     * 获得积分
     */
    @TableField("integral")
    private Integer integral;

    /**
     * 最终需支付价格，实付款
     */
    @TableField("price")
    private BigDecimal price;

    /**
     * 支付方式
     */
    @TableField("pay_type")
    private String payType;

    /**
     * 支付订单号
     */
    @TableField("pay_id")
    private String payId;

    /**
     * 物流单号
     */
    @TableField("logistics_number")
    private String logisticsNumber;

    /**
     * 物流类别
     */
    @TableField("logistics_type")
    private String logisticsType;

    /**
     * 物流类别编号
     */
    @TableField("logistics_code")
    private String logisticsCode;

    /**
     * 卖家物流地址id
     */
    @TableField("start_address_id")
    private Integer startAddressId;

    /**
     * 买家物流地址id
     */
    @TableField("end_address_id")
    private Integer endAddressId;

    /**
     * 卖家物流地址
     */
    @TableField("start_address_desc")
    private String startAddressDesc;

    /**
     * 买家物流地址
     */
    @TableField("end_address_desc")
    private String endAddressDesc;

    /**
     * 订单状态，待支付，未支付，代发货，运输中，也签收，也完结，待退款，已退款，已取消，审查中
     */
    @TableField("state")
    private String state;

    /**
     * 卖家留言
     */
    @TableField("message")
    private String message;

    /**
     * 是否删除
     */
    @TableField("useable")
    @TableLogic
    @JsonIgnore
    private String useable;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    /**
     * 普通用户删除标志
     */
    @TableField("user_flag")
    private Integer userFlag;

    /**
     * 管理员删除标志
     */
    @TableField("store_flag")
    private Integer storeFlag;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
